#include "IO.h"
#include <iostream>
#include <fstream>
#include <string>

Graph* 	file2Graph 	(string filename) {
	/* Extraction des données du fichier */
	ifstream in (filename.c_str(), ios_base::in);

	vector<vector<int> > data = vector<vector<int> >();
	data.push_back(vector<int>());

	bool countFromZero = false;

	int value,index = 0;
	while (in.good()) {
		if (in.peek() == '\n') {
			data.push_back(vector<int>());
			index++;
		}

		in >> value;

		if (value == 0)
			countFromZero = true;

		//cout << value << endl;

		data[index].push_back(value);

		if (!in.good()) {
			break;
		}
	}
	in.close();

	/* Création du graphe a partir des données extraites */
	int size;
	if (!countFromZero)
		for (int i=0; i<data.size(); i++)
			for (int j=0; j<data[i].size(); j++) {
				data[i][j]--;
			}

	return new Graph(data);
}

void 	graph2File 	(Graph graph, string filename) {

}
